<script>
    $(document).ready(function()
    {
        $("#show").on('change',function()
        {
            var url = "http://localhost/ci/admin/order/"+ $(this).val();
            window.location.replace(url);

        });
        $("#sortdate").on('click',function()
        {
            var url="http://localhost/ci/admin/order/bytime/" +$("#date1").val() + "/" + $("#date2").val();
            window.location.replace(url);
        })
    });
</script>
<p class="bold">Quản lý Order !</p>
<a class="show">Show:</a>
<select id="show">
    <option value="">--</option>
    <option value="0">0</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
</select>
<label>Date</label>
<input id="date1" type="date" id="my_date"> To <input id="date2" type="date" id="my_date" value="2014-09-08"> <button id="sortdate">Sort</button>
<?php
function stdToArray($obj){
    $reaged = (array)$obj;
    foreach($reaged as $key => &$field){
        if(is_object($field))$field = stdToArray($field);
    }
    return $reaged;
}

echo "<div class='order_box'>";
foreach ($list as $value)
{
     echo "<h3>";
     echo $value['order_name'];
     echo "</h3>";
     echo "<div id='function_order'>";
     if ($value['order_status']==0)
     {
         echo " Chưa Thanh Toán !";
     }
     else echo " Đã Thanh Toán !";
     echo "</div>";
     echo "<hr/>";
     echo "<p id='info'>";
     echo "Số ĐT:". $value['order_phone'];
     echo "<br>";
     echo "Địa Chỉ:". $value['order_add'];
     echo "</p>";
     $decode=json_decode($value['order_productid']);
     $pro=stdToArray($decode);
   echo "<table style='width: 700px'>";
   echo "<tr id='header'><td>Tên Sản Phẩm</td><td>Số Lượng</td><td>Đơn Giá</td></tr>";
   $total=0;
   foreach ($pro as $data => $key)
   {
    echo "<tr>";
       $this->load->model("Pagination_Model");
       $product=$this->Pagination_Model->getProduct($data);
       echo "<td>";
       echo $product['product_name'];
       echo "</td>";
       echo "<td>";
       echo $key;
       echo "</td>";
       echo "<td>";
       echo $product['product_price'];
       echo "</td>";
       $total= $total+($key*$product['product_price']);
    echo "</tr>";
   }
    echo "</table>";
    echo "<div class='total'><a>"."Tổng $: ". $total."</a>"."</div>";

}
?>

